package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.seller.TbTypeTemplateMapper;
import com.dongdongshop.pojo.seller.TbTypeTemplate;
import com.dongdongshop.pojo.seller.TbTypeTemplateExample;
import com.dongdongshop.service.TemplService;
import com.dongdongshop.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Service
@Component
public class TemplServiceImpl implements TemplService {

    @Autowired
    private TbTypeTemplateMapper templateMapper;

    @Override
    public PageBean<TbTypeTemplate> findTemplAll(String name, Integer pageNumber, Integer pageSize) {
        PageBean<TbTypeTemplate> page = new PageBean<>();
        page.setPageNumber(pageNumber);
        page.setPageSize(pageSize);

        List<TbTypeTemplate> list = templateMapper.findTemplAll(name,page.getStartIndex(),pageSize);
        page.setResult(list);

        Integer count = templateMapper.getcount();
        page.setTotalCount(count);
        return page;
    }

    @Override
    public void insertTempInfo(TbTypeTemplate template) {
        templateMapper.insertSelective(template);
    }

    @Override
    public int deleteByIds(Long[] ids) {
        return templateMapper.deleteByIds(ids);
    }

    @Override
    public TbTypeTemplate toUpdate(Long id) {
        return templateMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateInfo(TbTypeTemplate template) {
        templateMapper.updateByPrimaryKeySelective(template);
    }

    @Override
    public List<TbTypeTemplate> findInfoAll() {
        return templateMapper.selectByExample(new TbTypeTemplateExample());
    }

    @Override
    public TbTypeTemplate getItemTemplate(Long id) {
        return templateMapper.selectByPrimaryKey(id);
    }
}
